package co.baiku.boot.config;

import co.baiku.boot.common.tools.ObjectTools;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.List;
import java.util.Optional;

@ConfigurationProperties(prefix = "ajavaer.aliyun.sms")
public class AliyunSmsConfig {
    private String accessKeyId;
    private String accessKeySecret;

    private String signName;
    private String templateCode;

    /**
     * 模版列表
     */
    private List<AliyunSmsTemplate> templates;

    private String endpoint = "dysmsapi.aliyuncs.com";
    private String profile = "cn-hangzhou";
    private String regionId = "cn-hangzhou";
    private String product = "Dysmsapi";

    public AliyunSmsTemplate getByName(String templateName) {
        if (ObjectTools.isBlank(this.templates)) {
            return null;
        }
        Optional<AliyunSmsTemplate> first = getTemplates().stream().filter(item -> item.getName().equals(templateName)).findFirst();
        return first.orElse(null);
    }

    public List<AliyunSmsTemplate> getTemplates() {
        return templates;
    }

    public void setTemplates(List<AliyunSmsTemplate> templates) {
        this.templates = templates;
    }

    public String getAccessKeyId() {
        return accessKeyId;
    }

    public void setAccessKeyId(String accessKeyId) {
        this.accessKeyId = accessKeyId;
    }

    public String getAccessKeySecret() {
        return accessKeySecret;
    }

    public void setAccessKeySecret(String accessKeySecret) {
        this.accessKeySecret = accessKeySecret;
    }

    public String getEndpoint() {
        return endpoint;
    }

    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
    }

    public String getProfile() {
        return profile;
    }

    public void setProfile(String profile) {
        this.profile = profile;
    }

    public String getRegionId() {
        return regionId;
    }

    public void setRegionId(String regionId) {
        this.regionId = regionId;
    }

    public String getSignName() {
        return signName;
    }

    public void setSignName(String signName) {
        this.signName = signName;
    }

    public String getTemplateCode() {
        return templateCode;
    }

    public void setTemplateCode(String templateCode) {
        this.templateCode = templateCode;
    }

    public String getProduct() {
        return product;
    }

    public void setProduct(String product) {
        this.product = product;
    }
}
